package cn.itsource.pethome.system.user.controller;

import cn.itsource.pethome.base.controller.BaseController;
import cn.itsource.pethome.jwt.LoginContextUtils;
import cn.itsource.pethome.system.user.domain.Employee;
import cn.itsource.pethome.system.user.service.IEmployeeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@RestController
@RequestMapping("/emp")
//这里是说明你这个类是干什么用的
@Api(value = "员工的API",description="员工相关的CRUD功能")
public class EmployeeController extends BaseController<Employee> {
    @Autowired
    private IEmployeeService employeeService;
    @Autowired
    private LoginContextUtils loginContextUtils;

    @GetMapping("/list")
    @ApiOperation(value = "获取所有的员工信息" )
    public List<Employee> findAll(){
        return employeeService.findAll();
    }

    @GetMapping("/shopEmployee")
    @ApiOperation(value = "根据店铺的id去查询所有员工" )
    public List<Employee> findAll(HttpServletRequest request){
        Employee employee = (Employee)loginContextUtils.getLoginUser(request);
        return employeeService.findEmpByShopId(employee.getShopId());
    }
}
